package com.api.shopapi.mapper;

import com.api.shopapi.entity.MedicinerStaffRel;
import com.api.shopapi.entity.dto.MedicinerStaffRelDTO;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface MedicinerStaffRelMapper {

    @Insert("insert into mediciner_staff_rel " +
            "(MedicinerStaffRelCode,MedicinerCode,StaffCode) " +
            "values (#{medicinerStaffRel.MedicinerStaffRelCode} ,#{medicinerStaffRel.MedicinerCode} ,#{medicinerStaffRel.StaffCode} )")
    int insert(@Param("medicinerStaffRel") MedicinerStaffRel medicinerStaffRel);

    @Delete("delete from mediciner_staff_rel where MedicinerCode=#{medicinerCode} and StaffCode=#{medicinerStaffCode}")
    int delByMedicinerCodeAndMedicinerStaffCode(@Param("medicinerCode") String medicinerCode, @Param("medicinerStaffCode") String medicinerStaffCode);

    @Select("select * from mediciner_staff_rel where MedicinerCode=#{medicinerCode} and StaffCode=#{medicinerStaffCode} limit 1")
    MedicinerStaffRel getByMedicinerCodeAndMedicinerStaffCode(@Param("medicinerCode") String medicinerCode, @Param("medicinerStaffCode") String medicinerStaffCode);

    @Select("select * from mediciner_staff_rel where MedicinerCode=#{medicinerCode}")
    List<MedicinerStaffRelDTO> getListByMedicinerCode(@Param("medicinerCode") String medicinerCode);

    @Select("select * from mediciner_staff_rel where StaffCode=#{staffCode} limit 1")
    MedicinerStaffRel getByStaffCode(@Param("staffCode") String staffCode);

    @Delete("delete from mediciner_staff_rel where medicinerStaffRelCode=#{medicinerStaffRelCode}")
    int delete(@Param("medicinerStaffRelCode") String medicinerStaffRelCode);


}
